<template>
    <div>
          <div class="headstyle">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="grid-content bg-purple">
            <span class="locsty">
              <i class="el-icon-location iconsty"></i>当前位置：综合考试配置
            </span>
          </div>
        </el-col>
      </el-row>
    </div>
    <div style="text-align:right;margin-top:10px;margin-right:220px;">
                      <el-button type="primary" @click="savedate">保存配置</el-button>
                   </div>
    <div>
          <el-divider content-position="left">试题组卷配置</el-divider>
           <el-row :gutter="20">
                <el-col :span="8" style="text-align:center;border-right-style: dotted">
                   <div >
                     <h3 style="text-align:center">判断题</h3>
                     题数
                    <el-input-number size="medium" v-model="jdugenum"  :step="1" step-strictly  :min="1" :max="jdugemax" label=""></el-input-number>
                     <p style="color:red">当前题库有{{jdugemax}}道题</p>
                   </div>
                   <div>
                      分数
                      <el-input-number size="medium" v-model="jdugescore" @change="handleChange" :step="1" step-strictly  :min="0" label=""></el-input-number>
                   </div> 
                </el-col>  
                <el-col :span="8" style="text-align:center;border-right-style: dotted">
                   <div >
                     <h3 style="text-align:center">选择题</h3>
                     题数
                     <el-input-number size="medium" v-model="selectnum"   @change="handleChange" :step="1" step-strictly :min="0" :max="selectmax" label=""></el-input-number>
                     <p style="color:red">当前题库有{{selectmax}}道题</p>
                   </div>
                   <div>
                      分数
                      <el-input-number size="medium" v-model="selectscore"  @change="handleChange" :step="1" step-strictly  :min="0" label=""></el-input-number>
                   </div>
                </el-col>
                 
                <el-col :span="8" style="text-align:center">
                   <div >
                     <h3 style="text-align:center">多选题</h3>
                     题数
                     <el-input-number size="medium" v-model="manynum"  @change="handleChange"  :step="1" step-strictly :min="0" :max="manymax" label=""></el-input-number>
                     <p style="color:red">当前题库有{{manymax}}道题</p>
                   </div>
                   <div>
                      分数
                      <el-input-number size="medium" v-model="manyscore"  @change="handleChange" :step="1" step-strictly  :min="0" label=""></el-input-number>
                   </div>
                </el-col>
          </el-row>

    </div>
    <div>
        <el-divider content-position="left">试卷分数配置</el-divider>
        <el-row>
            <el-col :span="8" style="text-align:center">
                   <div >
                     <h3 style="text-align:center">总分</h3>
                  
                     <el-input-number size="medium" v-model="totalscore" :disabled="true" :step="1" step-strictly :min="1"  label=""></el-input-number>
                      <h3 style="text-align:center">及格分</h3>
                   </div>
                   <div>
                      <el-input-number size="medium" v-model="passscore"  :step="1" step-strictly  :min="1" :max="totalscore" label=""></el-input-number>
                   </div>
                </el-col>
        </el-row>
      </div>
        <div>
        <el-divider content-position="left">试卷其它配置</el-divider>
        <el-row>
            <el-col :span="8" style="text-align:center;border-right-style: dotted">
                   <div >
                     <h3 style="text-align:center">考试时间</h3>
                &emsp;&emsp;
                     <el-input-number size="medium" v-model="examtime" :step="1" step-strictly :min="1"  label=""></el-input-number>
                    分钟
                   </div>
                  
                </el-col>
                 <el-col :span="8" style="text-align:center">
                   <div >
                     <h3 style="text-align:center">考试次数</h3>
                    &emsp;&emsp;
                     <el-input-number size="medium" v-model="examnum" :step="1" step-strictly :min="1"  label=""></el-input-number>
                    次
                   </div>
                  
                   
                </el-col>
        </el-row>
      </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            jdugenum:0,
            jdugemax:null,
            jdugescore:null,
            selectnum:0,
            selectmax:null,
            selectscore:null,
            manynum:0,
            manymax:null,
            manyscore:null,
            totalscore:null,
            passscore:null,
            examtime:null,
            examnum:null,
        }
    },
      mounted:function(){
          this.$axios//取题库数值
        .get("/Exam/getexambank", {
          params: { }
        })
        .then(res => {
          
          var arr=res.data.split(",")
          this.jdugemax=parseInt(arr[0])
        
          this.selectmax=parseInt(arr[1])
          this.manymax=parseInt(arr[2])

             this.$axios//取数据库考试配置
        .get("/Exam/getexamconfig", {
          params: { }
        })
        .then(res => {
           
          if(res.data=="False"){
            this.$confirm("当前题库为空，请先导入题库", '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        }).then(() => {
             this.$router.replace({ path:'/examimport'})
        })
          }else{
            if(res.data.examtime!=null){
              this.examtime=res.data.examtime
            }
            if(res.data.examnum!=null){
              this.examnum=res.data.examnum
            }
            if(res.data.examtotal!=null){
              this.totalscore=res.data.examtotal
            }
            if(res.data.examave!=null){
              this.passscore=res.data.examave
            }
            if(res.data.jduge_num!=null){

              this.jdugenum= res.data.jduge_num
               
            }
            if(res.data.jduge_score!=null){
              this.jdugescore=res.data.jduge_score
            }
            if(res.data.selection_num!=null){
              
              this.selectnum=res.data.selection_num
                
            }
             if(res.data.selection_score!=null){
              this.selectscore=res.data.selection_score
            }
             if(res.data.many_num!=null){
              this.manynum=res.data.many_num
              
            }
             if(res.data.many_score!=null){
              this.manyscore=res.data.many_score
            }
          }
        }); 

        }); 
        
      },
      methods:{
        handleChange(){
         this.totalscore=this.jdugenum*this.jdugescore+this.selectnum*this.selectscore+this.manynum*this.manyscore
        },
        savedate(){
          var list={
            examtime:this.examtime,
            examnum:this.examnum,
            examtotal:this.totalscore,
            examave:this.passscore,
            jduge_num:this.jdugenum,
            jduge_score:this.jdugescore,
            selection_num:this.selectnum,
            selection_score:this.selectscore,
            many_score:this.manyscore,
            many_num:this.manynum
          }
          this.$axios//取题库数值
        .put("/Exam/save", list)
        .then(res => {
             if(res.data=="OK"){
                this.$message({
            message: "考试配置保存成功！",
            type: "success"
          });
             }
        }); 
        }
      }
}
</script>
<style scoped>
.headstyle {
  border-bottom: 2px solid #e5e5e5;
  padding-bottom: 20px;
}
.locsty {
  font-size: 16px;
  font-family: "Microsoft YaHei";
}
.iconsty {
  color: #53b9fe;
  font-size: 22px;
}


</style>